package change;

import affilication.Affiliation;
import affilication.imp.UnionAffiliation;
import domain.Employee;
import exception.EmployeeException;

public class ChangeMemberTransaction extends ChangeAffiliationTransaction {
    private UnionAffiliation unionAffiliation;
    public ChangeMemberTransaction(int empId, int memeberId, double rate) {
        super(empId);
        unionAffiliation = new UnionAffiliation(memeberId, rate);
    }

    @Override
    public Affiliation getAffiliation() {
        return unionAffiliation;
    }

    @Override
    public void execute() throws EmployeeException {
        super.execute();
        Employee employee = payrollDatabase.getEmployee(getEmpId());
        payrollDatabase.addUnionMember(unionAffiliation.getMemberId(), employee);
    }
}
